welcome back now we just learned how to deal with missing values and we have another task to do that is dealing with outliers we have already learned that we can use our box plot as one of our visualization plots to detect the theoretical outliers and then we are going to use this tutorial specificallyto use IQR or Inter Quantile Wrench to detect and remove outliers so the setup you will need pandas as pd and matplotlib.pyplot as plt and then we can load our data set I have already uploaded here which is Nov2Temp.csv you can download this dataset from this module and then upload it into this file panel you can also upload it from here use the upload the button or you can drop the file into this place okay so as you can see our data is actually quite simple we have only 118 observations and we have only 2 attributes one is high represents the high temperature of that day and the low which is the low temperature of that day and we can make a describe they were both numeric so we can use a describe to know the statistic understanding of them we can see the high has our mean of around 60 low has a min around 30 medium of them is a little bit different the shape is 118 observation and 2 attributes let's first check for the outliers as we know outliers can be detected by IQR we are going to use that low attribute in this tutorial and we are going to use the high for you to practice let's first show our outliers in the low by using our histogram because histogram shows the frequency of the observation using bins and we can see that this will be a typical distribution of your data and we definitely have some tail along the lower side and if we use our box plot as and low we can see definitely we can see the normal distributions right here and our climbers are detected all on the lower side but the next question is now we can see them how we can find them and remove them or separate them because again outliers are just some abnormal data points they may be the data you want to know more and they may be the value your analysis should be so not just to remove them and get rid of them ignore them but you need to separate them and because again outliers are not errors outliers might be the value okay so we learned that IQR is actually used be used for the outlier detection and we learned that in box plots how this lower bar is calculated the lower bar is actually Q1 -1.5 IQR so we first need to calculate what is your IQR that is your Q3 - Q1 you get Inter Quantile Range that is IQR then you can have your lower limit as Q1 - 1.5 IQR then you can print out that 4.875 which is exactly this bar so this will be your lower limit any number that is less than this lower limit such as this one will be your outliers and we can do the same thing for the low temperature high limit that is your Q3 + 1.5IQR the IQR is the same for the entire column and then we can see that the limit is actually 55.875 so that will be the bar we can draw right here and clearly we do not have any data higher than the high limit but we do have the data in here lower than the low limit which is your observation 41 79 109 110 and 111 and we have the specified low value here as you can see all below this theoretical lower limit then the next thing is quite simple we just need to drop these 5 rows and we learned in pandas that manipulation is quite easy just drop that row and then that will be fine and we also learned how to detect the high limit as it is clearly that we don't have any outliers for the high limit that is why we see nothing here so to remove the outliers again you just need to drop them so drop anything lower than the limit that index which means that you are going to drop the results from this filtering and then you are going to drop all the indexes in that filtering and then we learned from our missing value already if you are going to do this change to the data frame you have the inplace equal to True can just give you the original data frame modified rather than you have to assign it to a new data frame etc so this will basically drop all the data points that has a lower value than the theoretical low and the second line even though we have no value higher than the theoretical high but we still just put it here so that you know how to use these 2 lines to remove the outliers and let's check the result after removing the data points as outliers we can see our histogram is much more nicer with all the value in terms of they are more in a condensed distribution rather than with a really really long tail and now we can use our box plot to check the outliers as well as you can see here now we have no outliers detected that will be a simple application of using IQR to detect and to remove the outliers I will ask you to do the same thing for our high temperature and they are quite similar to what we have done for the low I'll see you in next lesson